import aes from 'crypto-js/aes'
import utf8 from 'crypto-js/enc-utf8'
import hex from 'crypto-js/format-hex'
import openssl from 'crypto-js/format-openssl'
import mode from 'crypto-js/mode-ecb'
import padding from 'crypto-js/pad-pkcs7'

const key = utf8.parse('A-16-Byte-keyValA-16-Byte-keyVal')

export const encrypt = (str, o) =>
  aes.encrypt(str, key, { mode, padding }).toString(o ? openssl : hex)

export const decrypt = str =>
  aes.decrypt(str, key, { mode, padding }).toString(utf8)
